print("------------ 默认初始化器 ------------")
class ShoppingListItem {
    var name: String?
    var quentiti = 1
    var purchased = true
}
var item = ShoppingListItem()
print(item)
print(item.name ?? 123456)
print(item.quentiti)
print(item.purchased)

print("------------ 指定初始化器 && 便捷初始化器(convenience) ------------")
class Person {
    var name: String
    var age: Int
    init(name: String, age: Int) {
        self.name = name
        self.age = age
    }
    convenience init() {
        self.init(name: "XiaoXiang", age: 18)
    }
}

class Teacher: Person {
    var salary: Int
    init(name: String, age: Int, salary: Int) {
        self.salary = salary
        super.init(name: name, age: age)
        self.name = self.name + "老师"
        test()
    }
    
    convenience init(salary: Int) {
        self.init(name: "XiaoXiang", age: 30, salary: salary)
        self.salary = salary + 2000
    }
    
    func test() {
        print("Teacher Test!")
    }
}

var tea = Teacher.init(name: "小想", age: 18, salary: 6000)
print(tea)
print(tea.name)
print(tea.age)
print(tea.salary)

var tea1 = Teacher.init(salary: 5000)
print(tea1)
print(tea1.name)
print(tea1.age)
print(tea1.salary)


